package com.xbongbong.pro.statistic.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 全景图模块分组
 * @author zcp
 * @version v1.0
 * @date 2019/5/29 16:07
 * @since v1.0
 */
@Getter
public enum PanoramaTeamEnum {

    /**
     * 客户详情页“全景图”，以“CUSTOMER_”开头
     */
    //跟进相关
    CUSTOMER_COMMUNICATE(XbbRefTypeEnum.CUSTOMER_MANAGEMENT, XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode() + "_01", ""),
    //机会相关
    CUSTOMER_OPPORTUNITY(XbbRefTypeEnum.CUSTOMER_MANAGEMENT, XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode() + "_02", ""),
    //报价单
    CUSTOMER_QUOTATION(XbbRefTypeEnum.CUSTOMER_MANAGEMENT, XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode() + "_05", ""),
    //合同资金相关
    CUSTOMER_CONTRACT(XbbRefTypeEnum.CUSTOMER_MANAGEMENT, XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode() + "_03", ""),
    //成交行为
    CUSTOMER_OK(XbbRefTypeEnum.CUSTOMER_MANAGEMENT, XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode() + "_04", ""),

    /**
     * 未知
     */
    UNKNOWN(XbbRefTypeEnum.UNKNOWN, XbbRefTypeEnum.UNKNOWN.getCode() + "", "enum.panoramaTeam.memo.unknown"),
    ;

    /**
     * 业务类型，代表是哪个业务的全景图
     */
    private XbbRefTypeEnum xbbRefTypeEnum;
    /**
     * 规则枚举code
     */
    private String code;
    /**
     * 该规则名
     */
    private String memo;

    PanoramaTeamEnum(XbbRefTypeEnum xbbRefTypeEnum, String code, String memo) {
        this.xbbRefTypeEnum = xbbRefTypeEnum;
        this.code = code;
        this.memo = memo;
    }

    /**
     * 获取某个业务的所有全景图分组
     * @param xbbRefTypeEnum 业务类型
     * @return java.util.List<com.xbongbong.pro.statistic.enums.PanoramaTeamEnum>
     * @author zcp
     * @date 2019/5/31 16:35
     * @since v1.0
     * @version v1.0
     */
    public static List<PanoramaTeamEnum> getByXbbRefType(XbbRefTypeEnum xbbRefTypeEnum) {
        List<PanoramaTeamEnum> list = new ArrayList<>();
        for (PanoramaTeamEnum cache : values()) {
            if (Objects.equals(cache.xbbRefTypeEnum, xbbRefTypeEnum)) {
                list.add(cache);
            }
        }
        return list;
    }

    public String getMemo() {
        return I18nMessageUtil.getMessage(memo);
    }
}
